﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class GetRiskItem : System.Web.UI.Page
{
    static int _rowNo = 0;
    static string chapterNo = "";
    protected void Page_Load(object sender, EventArgs e)
    {
        _rowNo = 0;
        //先从传入的地址中获取chapterNo,如果没有chapterNo就返回，反之就绑定单击后的效果
        chapterNo = Request.QueryString["ChapterNo"] != null ? Request.QueryString["ChapterNo"].ToString() : "";
        if (chapterNo == "")
            return;
        //开始从数据库中读取对应的数据，并与表绑定。
        string cmd = string.Format("SELECT [No],[Item],[TotalViewTimes] FROM [DataList] WHERE ([ChapterNo] = {0})", chapterNo);
        DBOperate myDB = new DBOperate();
        myDB.SetCommandString(cmd);
        GVRiskItem.DataSource = myDB.ExecuteReader();
        GVRiskItem.DataBind();
        myDB.CloseDB();

    }
    protected void GVRiskItem_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowIndex > -1)
        {
            e.Row.Cells[1].Text = string.Format("<a href=\"GetRiskItemDetail.aspx?ChapterNo={0}&DataNo={1}\">{2}</a>", 
                                                chapterNo, 
                                                e.Row.Cells[0].Text,
                                                e.Row.Cells[1].Text);
            e.Row.Cells[0].Text = (++_rowNo).ToString();
        }
    }
}
